package triannon.client.sprites.renderer;

import java.awt.Color;
import java.awt.Graphics2D;

public class HealthBarRenderer {
	private static final Color COLOR_GREEN = new Color(0, 255, 0, 155);
	private static final Color COLOR_RED = new Color(255, 0, 0, 155);
	private static final Color COLOR_YELLOW = new Color(255, 255, 0, 155);

	public void paint(Graphics2D g, int x, int y, double health, int width,
			int height) {
		if (health > 0d) {
			if (health > 0.66d) {
				g.setColor(COLOR_GREEN);
			} else if (health > 0.33d) {
				g.setColor(COLOR_YELLOW);
			} else {
				g.setColor(COLOR_RED);
			}

			g.fillRect(x + 1, y - height, (int) ((width - 2) * health) + 1,
					height - 1);

			g.setColor(Color.BLACK);

			g.drawRect(x, y - height - 1, width, height);

			// for (int i = 8; i < width; i += 8) {
			// g.drawLine(x + i, y - height, x + i, y - 1);
			// }
		}
	}
}
